import type {
  ButtonProps,
  DatePickerProps,
  FormInstance,
  FormItemProps,
  FormProps,
  InputNumberProps,
  InputProps,
  RadioGroupProps,
  SelectProps,
} from 'antd';
import type { CheckboxGroupProps } from 'antd/es/checkbox/Group';
import type { RangePickerProps } from 'antd/es/date-picker';
export type TSpan = {
  xs?: number;
  sm?: number;
  md?: number;
  lg?: number;
  xl?: number;
  xxl?: number;
  xxxl?: number;
};
export type TSubmitter = {
  onReset?: () => void;
  onSubmit: (newVals: Record<string, any>) => void;
  render?: (formInstance: FormInstance) => React.ReactNode;
  resetButtonProps?: ButtonProps;
  submitButtonProps?: ButtonProps;
  resetText?: string;
  submitText?: string;
};

export interface ValueTypeProps {
  type?:
    | 'input'
    | 'inputRange'
    | 'inputNumber'
    | 'date'
    | 'rangeDate'
    | 'select'
    | 'checkbox'
    | 'radio';
  inputProps?: InputProps;
  inputRangeProps?: InputProps;
  inputNumberProps?: InputNumberProps;
  datePickerProps?: DatePickerProps;
  rangePickerProps?: RangePickerProps;
  checkboxProps?: CheckboxGroupProps;
  radioGroupProps?: RadioGroupProps;
  selectProps?: SelectProps;
}

export interface YmQueryFilterProps<Value = any>
  extends Omit<FormProps<Value>, 'children'> {
  prefixCls?: string;
  span?: number | TSpan;
  labelWidth?: string | number;
  rootClassName?: string;
  rootStyle?: React.CSSProperties;
  onCollapsed?: (collapsed: boolean) => void;
  collapsed?: boolean;
  defaultCollapsed?: boolean;
  operColPosition?: 'inline' | 'right';
  submitter?: TSubmitter;
  hiddenReset?: boolean;
  formItems: (Omit<FormItemProps<Value>, 'children'> & {
    valueType?: ValueTypeProps;
  } & {
    children?: React.ReactNode;
    colProps?: { span?: number };
  })[];
  searchGutter?: number | object | any[];
  showHiddenNum?: boolean;
  collapseRender?: (collapsed: boolean, hiddenNum?: number) => React.ReactNode;
}

export interface QueryFilterContentProps {
  prefixCls: string;
  spanSize: { span?: number; layout?: string };
  onCollapsed?: (collapsed: boolean) => void;
  collapsed?: boolean;
  defaultCollapsed?: boolean;
  operColPosition?: 'inline' | 'right';
  submitter?: TSubmitter;
  hiddenReset?: boolean;
  formItems: YmQueryFilterProps['formItems'];
  formItemFixStyle: Record<string, any>;
  queryFilterFormInstance: FormInstance;
  searchGutter?: number | object | any[];
  showHiddenNum?: boolean;
  collapseRender?: (collapsed: boolean, hiddenNum?: number) => React.ReactNode;
}
